package br.ufpe.cin.msc.jrsj2.recommender.persistence.domain;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;

import com.google.appengine.api.datastore.Key;

@Entity
public class Profile {

	@Id
	private String id;

	@Basic
	private Key programId;

	@Basic
	private Key clientId;

	@Column(columnDefinition = "FLOAT DEFAULT 0")
	private Float rating;

	@Transient
	private Program program;

	@Transient
	private Client client;

	public Profile(Program program, Client client, float rating) {
		if (program.getId() == null || client.getId() == null) {
			this.id = null;
			this.setProgram(program);
			this.setClient(client);
		} else {
			this.setId(program.getId() + ":" + client.getId() + ":" + rating);
			this.setProgramId(program.getId());
			this.setClientId(client.getId());
		}
		this.rating = rating;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setProgramId(Key programId) {
		this.programId = programId;
	}

	public Key getProgramId() {
		return programId;
	}

	public void setClientId(Key clientId) {
		this.clientId = clientId;
	}

	public Key getClientId() {
		return clientId;
	}

	public void setRating(Float rating) {
		this.rating = rating;
	}

	public Float getRating() {
		return rating;
	}

	public void setProgram(Program program) {
		this.program = program;
	}

	public Program getProgram() {
		return program;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Client getClient() {
		return client;
	}

	public String toString() {
		return client.getHash() + ":" + program;
	}

}